#include <iostream>
using namespace std;
template <class T1, int len>
class arr
{
    template <class T, int len1>
    friend ostream &operator << (ostream & out, arr<T, len1> &a1);

public:
    arr()
    {
        this->p = new T1[len];
        for (size_t i = 0; i < len; i++)
        {
            this->p[i] = 0;
        }
    }
    ~arr()
    {
        delete[] this->p;
        this->p = NULL;
    }

public:
    T1 &operator[](int index)
    {
        return this->p[index];
    }

private:
    T1 *p;
};
template <class T, int len1>
ostream &operator<<(ostream &out, arr<T, len1> &a1)
{
    for (size_t i = 0; i < len1; i++)
    {
        out << a1.p[i] << endl;
    }
    return out;
}
int main(int argc, char *argv[])
{
    arr<int, 5> a1;
    for (int i = 0; i < 5; i++)
    {
        a1[i] = i;
    }
    cout << a1<<endl;
    return 0;
}
